  <nav>
  

            <ul class="primary_nav">
            <?php $kategoriler = $this->db->get('categories')->result(); ?>
            <?php foreach($kategoriler as $kategori): ?>
            <?php $this->db->select_min('category_id');
            $min = $this->db->get('categories')->row(0)->category_id;
             $cname = str_replace(' ', '-', $kategori->name);
             $cname = mb_strtolower($cname,'UTF-8');
             ?>
                <li <?php if($cname == urldecode($this->uri->segment(2))) echo 'class="active"'; ?>><?php echo anchor('urunler/'.$cname,$kategori->name); ?>
                    <!--SUbmenu Starts-->
                    
                    <ul class="sub_menu">
                    <?php $alt_kategoriler = $this->config_model->get_subcategories($kategori->category_id)->result(); ?>
                        <li> <a href="#"><?php echo $kategori->name; ?></a>
                            <ul>
                                <?php foreach($alt_kategoriler as $alt_kategori) :?>
                                 <?php $sname = str_replace(' ', '-', $alt_kategori->name);
             $sname = mb_strtolower($sname,'UTF-8'); ?>
                                <li><?php echo anchor('urunler/'.$cname.'/'.$sname,$alt_kategori->name); ?></li>
                                <?php endforeach; ?>
                            </ul>
                        </li>
                       
                    </ul>
                    <!--SUbmenu Ends-->
                </li>
                
           
               <?php endforeach; ?>
            </ul>
         <?php $this->load->view('partials/sepetim_nav'); ?>
        </nav>